package com.qidian.qc.controller;

import com.qidian.mes.pojo.qc.QcDefect;
import com.qidian.mes.pojo.qc.QcIndex;
import com.qidian.mes.util.pojo.MESResult;
import com.qidian.qc.service.QcDefectService;
import com.qidian.qc.service.QcIndexService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 53邹李萍
 * @Company 起点编程
 * @Time 2023/10/30 16:20
 * @Description
 */
@CrossOrigin
@RestController
@RequestMapping("/index")
public class QcIndexController {
    @Autowired
    QcIndexService qcIndexService;

    //编号生成
    @GetMapping("/generate")
    public MESResult generate(){
        return qcIndexService.generate();
    }

    @GetMapping("/get")
    public MESResult get(String indexCode){
        return qcIndexService.getIndexCode(indexCode);
    }
    @GetMapping("/list")
    public MESResult list(@RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10") int limit, QcIndex qcIndex){
        return qcIndexService.list(page,limit,qcIndex);
    }
    @PostMapping("/save")
    public MESResult save(@RequestBody QcIndex qcIndex){
        return qcIndexService.save(qcIndex);
    }

    @PostMapping ("/update")
    public MESResult update(@RequestBody QcIndex qcIndex){
        return qcIndexService.update(qcIndex);
    }

    @DeleteMapping("/delete")
    public MESResult delete(String indexCode){
        return qcIndexService.delete(indexCode);
    }

}
